package com.fengyi.library.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * 熔断器测试视图控制器
 * 用于处理熔断器测试页面的请求
 */
@Controller
@RequestMapping("/circuit-breaker-test")
public class CircuitBreakerViewController {

    /**
     * 显示熔断器测试页面
     * @param timeout 是否模拟超时，可选值：true/false
     * @param retry 是否启用重试，可选值：true/false
     * @param mode 熔断器模式，可选值：basic, timeout, retry
     * @param model 模型
     * @return 视图名称
     */
    @GetMapping
    public String showCircuitBreakerTestPage(
            @RequestParam(required = false, defaultValue = "false") boolean timeout,
            @RequestParam(required = false, defaultValue = "false") boolean retry,
            @RequestParam(required = false, defaultValue = "basic") String mode,
            Model model) {
        
        model.addAttribute("timeout", timeout);
        model.addAttribute("retry", retry);
        model.addAttribute("mode", mode);
        
        return "circuit-breaker-test";
    }
}